<template>
  <div class="ChildPage TablePage" v-loading="loading">
    <vb-page ref="page">

      <template #table-handle-prepend="scope">
        <el-button size="mini" type="text" icon="el-icon-edit" style="color: #E6A23C" @click="doDownload(scope.row.billNo)">下载</el-button>
      </template>

    </vb-page>

  </div>

</template>

<script>
import {getCurrentInstance} from "vue";

export default {
  components: {

  },
  data() {
    return {}
  },
  setup() {
    const { proxy } = getCurrentInstance()
    // 获取状态名称
    const getStatusName = status => {
      if (!proxy.$refs.page.data || !proxy.$refs.page.data.config || !proxy.$refs.page.data.config.column) return ''

      let columns = proxy.$refs.page.data.config.column;
      for(let i = 0; i < columns.length; i++) {
        if (columns[i].prop === 'status') {
          let dicData = columns[i].dicData
          for(let j = 0; j < dicData.length; j++) {
            if (dicData[j].key === status) {
              return dicData[j].name
            }
          }
        }
      }
      return ''
    }
    return {
      getStatusName
    }
  },
  methods: {
    //导出excle
    async doDownload(billNo) {
      this.loading = true
      try {
        let res = await this.callApi('download_sync_history', {billNo : billNo})
        if (!res.res) return
      } finally {
        this.loading = false
      }
    },
    doSelect(data) {
      this.selection = data
      this.selectionLength = this.selection.length;
      this.selectCount=0
      for (var i=0;i<this.selectionLength;i++){
        this.selectCount+=data[i].count
      }
      this.selectCount = parseFloat(this.selectCount).toFixed(2)
      // console.log(this.selection)
      // console.log(data[0].billNo)
    },
    async redoIntegrate(scope) {
      try {
        this.loading = true
        await this.callApi("retry", {
          id: scope.row.id
        })
        this.$message.success('重推完成')
      } finally {
        this.$refs.page.data.reload()
        this.loading = false
      }
    },
  }

}
</script>

<style scoped>

</style>
